package com.wmyg.antifake.repository;

import com.wmyg.antifake.entity.BkUser;
import com.wmyg.antifake.entity.Company;
import com.wmyg.antifake.entity.Order;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * @author 王卓逸
 * @program TODO
 * @description TODO
 * @create 2019-05-26
 */
@Repository
public interface OrderRepository extends JpaRepository<Order, Integer> {

    Order findByOrderId(Integer orderId);

    Order findByWxpayId(String wxpayId);

    Page<Order> findByCompanyOrderByCreateTimeDesc(Company company, Pageable pageable);

    Page<Order> findByCompanyAndCreateTimeBetweenOrderByCreateTimeDesc(Company company, Date startTime, Date endTime, Pageable pageable);

    Page<Order> findByCompanyAndCreateTimeBeforeOrderByCreateTimeDesc(Company company, Date endTime, Pageable pageable);

    Page<Order> findByCompanyAndOrderStateOrderByCreateTimeDesc(Company company, Integer orderState, Pageable pageable);

    Page<Order> findByCompanyAndOrderStateAndCreateTimeBetweenOrderByCreateTimeDesc(Company company, Integer orderState, Date startTime, Date endTime, Pageable pageable);

    Page<Order> findByCompanyAndOrderStateAndCreateTimeBeforeOrderByCreateTimeDesc(Company company, Integer orderState, Date endTime, Pageable pageable);

    Page<Order> findByCompanyAndOrderStateLessThanOrderByCreateTimeDesc(Company company, Integer orderState, Pageable pageable);

    Page<Order> findByCompanyAndOrderStateLessThanAndCreateTimeBetweenOrderByCreateTimeDesc(Company company, Integer orderState, Date startTime, Date endTime, Pageable pageable);

    Page<Order> findByCompanyAndOrderStateLessThanAndCreateTimeBeforeOrderByCreateTimeDesc(Company company, Integer orderState, Date endTime, Pageable pageable);

}
